import React, { useEffect, useState } from 'react';
import { Modal, Form, Space } from 'antd';
import FormCondition from '@/components/FormCondition';
import { connect, history } from 'umi';
import { Button, Row, Col } from 'antd';
const CheckOrderForm = (props) => {
  const { visible = false, onClose, loading, dispatch, handleCallback, } = props;
  const { show = false, detail = {} } = visible;
  const { orderSn, } = detail;
  const [status, setStatus] = useState(null)
  const [form] = Form.useForm();
  // 确认提交
  const handleUpAudit = () => {
    form.validateFields().then((values) => {
      dispatch({
        type: 'commission/fakeConfirmDistribute', payload: values, callback: () => {
          // onClose()
          // handleCallback()
          history.goBack()
        }
      })

    });
  };
  useEffect(() => {
    if (!show) {
      setStatus(null)
    }
  }, [show])
  const formItems = [
    {
      label: `订单编号`,
      name: 'orderSn',
      disabled: true
    },
    {
      label: `审核状态`,
      name: 'status',
      type: 'select',
      style: { textAlign: 'left' },
      select: {
        1: '通过',
        2: '作废'
      },
      disabled: true
    },
 
    {
      label: `备注`,
      name: 'confirmRemark',
      type: 'textArea',
      rules: [{ required: false }],
    },

  ];

  const modalProps = {
    title: '确认作废',
    width: 1200,
    visible: show,
    maskClosable: true,
    destroyOnClose: true,
    zIndex: 1001,
    confirmLoading: loading,
  };

  return (
    <Modal {...modalProps} onCancel={onClose} onOk={handleUpAudit}>
      <Space direction={'vertical'} style={{ display: 'flex', textAlign: 'center', justifyContent: 'center', width: '100%' }}>
        <FormCondition form={form} initialValues={{
          orderSn,
          status: '2',
        }} formItems={formItems}></FormCondition>
      </Space>

    </Modal >
  );
};

export default connect(({ order, loading }) => ({
  loading: loading.effects['order/fakeCheckOrder'],
}))(CheckOrderForm);
;
